from app.db.mongoClient import ErrMongoClient, get_mongo_client
from . import dbSynPosServer, collectionServerList


def querySchoolNameLogo():
    '''
    查询学校名称及logo
    '''
    try:
        mg_client = get_mongo_client()
        res = mg_client[dbSynPosServer][collectionServerList].find_one()
        if res is not None:
            data = {
                'schoolName': res.get('schoolName'),
                'schoolLogo': res.get('schoolLogo')
            }
            return data
            
        return None   
    except Exception as e:
        raise ErrMongoClient.data(str(e))


def queryRolePower():
    '''
    查询系统可导出的所有权限
    '''
    try:
        mg_client = get_mongo_client()
        res = mg_client[dbSynPosServer][collectionServerList].find_one()
        if res is not None:
            return res.get('rolePower')
            
        return None   
    except Exception as e:
        raise ErrMongoClient.data(str(e))